package exp;

import exp.logger.LoggerException;


/**
 * Very abstract class to represent an experiment
 * 
 * @author bastian marquis
 */
public abstract class Experiment {
	
	/**
	 * The current position in the tree
	 * Points at the root of the "tree" at the beginning of the experiment
	 */
	private Node currentPos;
	
	/**
	 * The root of the experiment
	 */
	private Node root;
	
	/**
	 * Setter for currentPos
	 * 
	 * @param pos new pos
	 */
	public void setCurrentPos(Node pos){
		currentPos = pos;
	}
	
	/**
	 * Getter for root 
	 * @return root
	 */
	public Node getRoot() {
		return root;
	}

	/**
	 * Setter for root
	 * @param root new root
	 */
	public void setRoot(Node root) {
		this.root = root;
	}
	
	/**
	 * Getter for currentPos
	 * 
	 * @return currentPos
	 */
	public Node getCurrentPos(){
		return currentPos;
	}
	
	/**
	 * Take right road
	 * @throws LoggerException 
	 */
	public void takeRight() throws LoggerException{
		currentPos = currentPos.getRightNode();
	}
	
	/**
	 * Take left road
	 * @throws LoggerException 
	 */
	public void takeLeft() throws LoggerException{
		currentPos = currentPos.getLeftNode();
	}
	
	/**
	 * @return true if the children reached a leaf, false otherwise
	 */
	public boolean isEnd(){
		return currentPos.isLeaf();
	}
	
	/**
	 * Reset the experiment
	 * @throws LoggerException 
	 */
	public abstract void reset() throws LoggerException;
	
	/**
	 * Read an experiment from a file
	 * @param file the path to the file containing the experiment
	 */
	public abstract void readFromFile(String file);
}
